- Home
·
- Miscellaneous
·
- Find any part of a string in a ListView. Click Go > to continue to next occurence
Find any part of a string in a ListView. Click Go > to continue to next occurence
Find any part of a string in a ListView. Click Go > to continue to next occurence
API Declarations
Add a Command Button - cmdGo Caption - Go >
To find next, click Go > again
Rate Find any part of a string in a ListView. Click Go > to continue to next occurence
(1(1 Vote))
txtFind_Lookup
End Sub
Private Sub txtFind_Lookup()
Dim lvwItm As ListItem
Dim Itm As Integer
Dim SubItm As Integer
Dim strSrch As String
If txtFind > "" Then
Set lvwItm = ListView1.FindItem(txtFind.Text, , , lvwPartial) 'Search Items
doagain:
If lvwItm Is Nothing Then ' Search Subitems
Itm = 0: SubItm = 0
For Itm = LastItm To ListView1.ListItems.Count
If InStr(1, UCase(ListView1.ListItems.Item(Itm)), UCase(txtFind.Text)) Then
Set lvwItm = ListView1.ListItems.Item(Itm)
GoTo Out01
End If
For SubItm = 1 To 10 'Search first 10 Subitems CHANGE AS NEEDED
strSrch = ListView1.ListItems.Item(Itm).ListSubItems.Item(SubItm).Text
If InStr(1, UCase(strSrch), UCase(txtFind.Text)) Then
Set lvwItm = ListView1.ListItems.Item(Itm)
GoTo Out01
End If
Next SubItm
Next Itm
LastItm = Itm
If LastItm >= ListView1.ListItems.Count Then LastItm = 1: GoTo doagain
Exit Sub 'Not found
Out01:
LastItm = Itm + 1
If LastItm > ListView1.ListItems.Count Then LastItm = 1
lvwItm.EnsureVisible
lvwItm.Selected = True
ListView1.SetFocus
Else
lvwItm.EnsureVisible
lvwItm.Selected = True
ListView1.SetFocus
End If
End If
End Sub
Find any part of a string in a ListView. Click Go > to continue to next occurence Comments
No comments yet — be the first to post one!
Post a Comment